﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Presenters.WEB;
using Presenters.WEB.Views;
using Model;
using System.Web.Security;

namespace AirlinePilotAcedemy_WEB
{
    public partial class Login : System.Web.UI.Page, ILoginView
    {
        LoginPresenter presenter;
        bool allowedToLogin { get; set; }
        
        protected void Page_Load(object sender, EventArgs e)
        {
            presenter = new LoginPresenter(this);
            this.allowedToLogin = false;
        }

        protected void SubmitB_Click(object sender, EventArgs e)
        {
            presenter.SubmitLoginWEB();
            allowedToLogin = presenter.userExists;
            if (allowedToLogin)
            {
                bool persistent = rememberCB.Checked;
                FormsAuthentication.RedirectFromLoginPage(usernameTB.Text, persistent);
            }
        }
        public string username
        {
            get { return usernameTB.Text; }
        }
        public string password
        {
            get { return passwordTB.Text; }
        }
        public string Message
        {
            set { messageL.Text = value; }
        }
        public bool userExits
        {
            set { allowedToLogin = value; }
        }

    }
}